using System.Collections.Generic;
using System.Linq;
using System.Text;
using System;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
using GameVuTru.ManagerScreens;
using GameVuTru.ResourceManager;

namespace GameVuTru.GameObject
{
    class ItemBonus : CObject
    {
        public BONUSTYPE bonustype;
        public Vector2 veclocCoin;
        Random rd = new Random();
        //  bool checkcoinhit;//kiem tra xem dong tien da cham 480 chua, chan roi ko cho no nhay len nua
        public ItemBonus(Vector2 pos, BONUSTYPE type)
        {
            bonustype = type;
            postion = pos;
            if (bonustype == BONUSTYPE.COINBOX)
            {
                m_sprite = new CSprite(ReSouce.coinItem, 7, 7, 175, 25);
            }
            if (bonustype == BONUSTYPE.REDBOX || bonustype == BONUSTYPE.THREECOLORBOX || bonustype == BONUSTYPE.YELLOWBOX || bonustype == BONUSTYPE.BLUEBOX || bonustype == BONUSTYPE.SHIELD)
            {
                m_sprite = new CSprite(ReSouce.bulletItem, 4, 4, 160, 40);
            }
            //  checkcoinhit = false;
            isvisible = true;
            speed = 5;
            typeobject = OBJECTTYPE.BONUS;
            veclocCoin = new Vector2(rd.Next(-7, 7), -10);
        }
        public override void Update(GameTime gametime)
        {
            if (isvisible)
            {

                switch (bonustype)
                {
                    case BONUSTYPE.REDBOX:
                        m_sprite.UpdateSprite(gametime, 0, 0, 1);
                        break;
                    case BONUSTYPE.BLUEBOX:
                        m_sprite.UpdateSprite(gametime, 2, 2, 1);
                        break;
                    case BONUSTYPE.YELLOWBOX:
                        m_sprite.UpdateSprite(gametime, 1, 1, 1);
                        break;
                    case BONUSTYPE.SHIELD:
                        m_sprite.UpdateSprite(gametime, 3, 3, 1);
                        break;
                    case BONUSTYPE.THREECOLORBOX:
                        m_sprite.UpdateSprite(gametime, 0, 2, 1);
                        break;
                    case BONUSTYPE.COINBOX:
                        m_sprite.UpdateSprite(gametime, 0, 6, 1);
                        break;
                    default:
                        break;
                }
                if (bonustype == BONUSTYPE.COINBOX)
                {
                    postion += veclocCoin;
                    veclocCoin.Y++;
                    //if (checkcoinhit)
                    //{
                    //    veclocCoin.X = 0;
                    //    postion.Y = 480 - m_sprite.heightsprite / 2;
                    //}
                    //if (postion.Y >= 480 - m_sprite.heightsprite / 2 && !checkcoinhit)
                    //{
                    //    veclocCoin.Y = -20;
                    //    checkcoinhit = true;
                    //}

                }
                else
                {
                    postion.Y += speed;
                }

                base.Update(gametime);
            }

        }
        public override void UpdateCollion(CObject b)
        {
            base.UpdateCollion(b);
        }
        public override void Draw(SpriteBatch sp)
        {
            if (isvisible)
                base.Draw(sp);

        }

    }
}
